package com.huawei;

import java.util.*;

/**
 * Created by Z-hong on 2024/7/17.
 */

public class HJ36 {
    public static String letter = "abcdefghijklmnopqrstuvwxyz";
    public static char[] wordArr=new char[26];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ser = sc.next();
        String word = sc.next();
        encipher(ser);
        char[] charArray = word.toCharArray();

        for (int i = 0; i < charArray.length; i++) {
            int a=charArray[i]-'a';
            charArray[i]=wordArr[a];
        }
        System.out.println(String.valueOf(charArray));

    }

    public static void encipher(String str) {
        char[] charArray = str.toCharArray();
        int[] arr = new int[26];
        char[] res = new char[26];
        int index = 0;
        for (int i = 0; i < charArray.length; i++) {
            if (arr[charArray[i] - 'a'] == 0) {
                arr[charArray[i] - 'a'] = 1;
                res[index++] = charArray[i];
            }
        }
        char[] letterArr = letter.toCharArray();
        for (int i = 0; i < letterArr.length; i++) {
            if (arr[letterArr[i] - 'a'] != 1) {
                res[index++] = letterArr[i];
            }
        }
        wordArr=res;
    }
}
